package com.yxhl.zoume.data.http.rest.param.busticket;

import com.yxhl.protobuf.OneBusEntry;
import com.yxhl.zoume.data.http.model.passenger.ZMPassenger;
import com.yxhl.zoume.data.http.rest.param.base.BaseRequestParam;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Xboy on 16/4/26.
 */
public class LockTicketsParam extends BaseRequestParam {

    //系统相关
    private String clientSystem;
    private String clientVersion;

    //取票人相关
    //身份证号
    private String idNumber;
    //姓名
    private String name;
    //取票手机号
    private String getTicketMobile;

    //乘客相关
    private int amount;//购票张数 (最大五张)
    //联系人数据列表
    private List<PassengerInfo> contracts;

    //目的地编号
    private String end;
    //目的地编号
    private String endStationCode;
    //始发车站编号
    private String startStationCode;
    //发车日期
    private String gmtDepartDate;
    //发车时间
    private String gmtDepartTime;
    //车次编号
    private String scheduleNo;


    public LockTicketsParam(String mobile, String token,
                            OneBusEntry busService, List<ZMPassenger> passengers, ZMPassenger taker) {
        super(mobile, token);

        this.contracts = new ArrayList<PassengerInfo>();
        for (ZMPassenger p : passengers) {
            PassengerInfo info = new PassengerInfo();
            info.setRealname(p.getRealName());
            info.setMobile(p.getMobileNumber());
            info.setIdNumber(p.getIdNumber());
            info.setIdType("0");
            info.setContractType(p.getPsgerCategory());
            this.contracts.add(info);
        }

        this.amount = passengers.size();

        this.idNumber = taker.getIdNumber();
        this.name = taker.getRealName();
        this.getTicketMobile = taker.getMobileNumber();

        this.end = busService.getEndStationCode();
        this.endStationCode = busService.getEndStationCode();
        this.startStationCode = busService.getStartStationCode();
        this.gmtDepartDate = busService.getGmtDepartDate();
        this.gmtDepartTime = busService.getGmtDepartTime();
        this.scheduleNo = busService.getScheduleNo();
    }

    public void setClientSystem(String clientSystem) {
        this.clientSystem = clientSystem;
    }

    public void setClientVersion(String clientVersion) {
        this.clientVersion = clientVersion;
    }

    private class PassengerInfo {
        private int contractType;
        private String realname;
        private String idNumber;
        private String idType;
        private String mobile;

        public int getContractType() {
            return contractType;
        }

        public PassengerInfo setContractType(int contractType) {
            this.contractType = contractType;
            return this;
        }

        public String getRealname() {
            return realname;
        }

        public PassengerInfo setRealname(String realname) {
            this.realname = realname;
            return this;
        }

        public String getIdNumber() {
            return idNumber;
        }

        public PassengerInfo setIdNumber(String idNumber) {
            this.idNumber = idNumber;
            return this;
        }

        public String getIdType() {
            return idType;
        }

        public PassengerInfo setIdType(String idType) {
            this.idType = idType;
            return this;
        }

        public String getMobile() {
            return mobile;
        }

        public PassengerInfo setMobile(String mobile) {
            this.mobile = mobile;
            return this;
        }
    }
}
